<template>
  <div>
    <!-- 搜索和筛选区域 -->
    <el-form :inline="true" :model="doctororderform" class="demo-form-inline">
      <el-form-item label="姓名">
        <el-input v-model="doctororderform.patientName" placeholder="请输入患者姓名"></el-input>
      </el-form-item>
      <el-form-item label="订单编号">
        <el-input v-model="doctororderform.orderId" placeholder="订单编号"></el-input>
      </el-form-item>
      <el-form-item label="处方状态">
        <el-select v-model="doctororderform.prescriptionStatus" placeholder="处方状态">
          <el-option
            v-for="item in options"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search">查询</el-button>
        <el-button @click="resetForm()">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格区域 -->
    <el-table :data="DOlist"
              style="width: 100%">
      <!--            <el-table-column prop="index" label="序号" ></el-table-column>-->
      <el-table-column prop="orderId" label="订单编号"></el-table-column>
      <el-table-column prop="prescriptionId" label="处方编号" ></el-table-column>
      <el-table-column prop="patientName" label="患者姓名"></el-table-column>
      <el-table-column prop="phoneNumber" label="电话"></el-table-column>
      <el-table-column prop="department" label="科室"></el-table-column>
      <el-table-column prop="doctorName" label="医生"></el-table-column>
      <el-table-column prop="orderAmount" label="订单金额"></el-table-column>
      <el-table-column prop="orderStatus" label="订单状态"></el-table-column>
      <el-table-column prop="prescriptionStatus" label="处方状态"></el-table-column>
      <el-table-column prop="medicationMethod" label="购药方式"></el-table-column>
      <el-table-column prop="dispensationStatus" label="发药状态"></el-table-column>
      <el-table-column prop="createdAt" label="创建时间"></el-table-column>
      <el-table-column prop="updatedAt" label="更新时间"></el-table-column>
    </el-table>

    <!-- 分页区域 -->
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNum"
      :page-sizes="[5,10,15]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import { OrderList } from '@/api/doctororder/doctororder'

export default {
  name: "",
  data() {
    return {
      DOlist: [],
      doctororderform:{
        orderId: '',
        prescriptionId: '',
        patientName: '',
        phoneNumber: '',
        department: '',
        doctorName: '',
        orderAmount: '',
        orderStatus: '',
        prescriptionStatus: '',
        medicationMethod: '',
        dispensationStatus: '',
        createdAt: '',
        updatedAt: '',
      },
      options:[
        { value: '已开立', label: '已开立' },
        { value: '未开立', label: '未开立' },
      ],
      pageNum: 1,
      pageSize: 10,
      total: 0,
    }
  },
  methods: {
    getOrderList() {
      OrderList({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        patientName: this.doctororderform.patientName,
        orderId: this.doctororderform.orderId,
        prescriptionStatus: this.doctororderform.prescriptionStatus,
      }).then(res => {
        this.DOlist = res.data.list
        this.total = res.data.total
      })
    },
    search() {
      this.pageNum = 1
      this.getOrderList()
    },
    resetForm(){
      this.doctororderform = {}
    },
    handleSizeChange(size) {
      this.pageSize = size;
      this.getOrderList();
    },
    handleCurrentChange(currentPage) {
      this.pageNum = currentPage;
      this.getOrderList();
    },
  },
  created() {
    this.getOrderList()
  },
}
</script>

<style scoped lang="scss">

</style>
